package com.example.nacosConsumer.controller;

import com.example.nacosConsumer.entity.Customer;
import com.example.nacosConsumer.service.ConsumerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 顾客服务controller
 */
@RestController
@RequestMapping("/consumer")
@Slf4j
public class ConsumerController {

    @Autowired
    ConsumerService consumerService;

    /**
     * 测试接口1
     * @param name 姓名
     * @return
     */
    @GetMapping
    @ResponseBody
    public String getHelloMsg(@RequestParam("name") String name){
        log.info("服务消费者端传递的name参数是：{}",name);
        return consumerService.hello(name);
    }

    /**
     * 测试接口2
     * @param customer 顾客信息实体对象
     * @return
     */
    @PostMapping
    public String insertInfo(@RequestBody Customer customer){
        log.info("服务消费者端传递的customer参数是：{}",customer.toString());
        return consumerService.insertInfo(customer);
    }
}
